package com.demo.apparel.controller.uniapp;

import com.demo.apparel.common.Result;
import com.demo.apparel.dto.PlatformVisitDTO;
import com.demo.apparel.dto.uniapp.VisitRecordDTO;
import com.demo.apparel.entity.VisitCountDaily;
import com.demo.apparel.service.uniapp.PlatformVisitService;
import com.demo.apparel.service.uniapp.VisitCountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx/visit")
@Tag(name = "访问统计模块", description = "记录并查询访问量")
public class VisitCountController {

    @Autowired
    private VisitCountService visitCountService;

    @Autowired
    private PlatformVisitService platformVisitService;
    @PostMapping("/record")
    @Operation(summary = "记录访问量主要是用miniapp作为标识")
    public Result<Void> recordVisit(@RequestBody VisitRecordDTO dto) {
        visitCountService.recordVisit(dto.getUri());
        return Result.success();
    }
    /**
     *
     * @param
     * @return
     */
    @PostMapping("/recordDaily")
    @Operation(summary = "每天的访问提交信息主要是用miniapp")
    public Result<Void> recordVisitDaily(@RequestBody VisitRecordDTO dto) {
        visitCountService.recordVisitDaily(dto.getUri());
        return Result.success();
    }

    @PostMapping("/add")
    @Operation(summary = "上传各个平台的访问量标识")
    public Result<Void> recordVisit(@RequestParam String uri, @RequestParam String platform) {
        platformVisitService.recordVisit(uri, platform);
        return Result.success();
    }



}
